<?php

class thetape_scraper extends BlogScraper
{
    var $date;
    
    function __construct()
    {
        parent::__construct('thetape');
    }
    
    function getPostLinks()
    {
        return $this->xpath->query('//h2//a');
    }
}

class thetape_post_scraper extends PostScraper
{

    
    function getPostLinks()
    {
        return $this->xpath->query("//html//body//div[@class='post'][{$this->post_index}]//a");
    }
    
    function getTitle()
    {
        return $this->xpath->query('//h2//a')->item(0)->nodeValue;
    }
    
    function getLink()
    {
        return $this->xpath->query('//h2//a')->item(0)->getAttribute('href');
    }  
        
    function getDate()
    {
        $date = $this->xpath->query("//html//body//div[@class='post']//h3")->item(0)->nodeValue;
        list($day_name, $date) = explode(' on ', $date, 2);
        list($day_name, $date, $time) = explode(',', $date);
        $date = $date.substr(trim($time), 0, 4);
        $date = str_replace(" of", "", $date);
        echo $date;
        return date('Y-m-d H:i:s', strtotime($date));

    }
    
    function prepareTrack($track)
    {
        $track['name'] = str_replace('[click to download]', '', trim($track['name']));
        
        //they use [artist]- [song]
        $name_parts = explode('-', $track['name']);
        
        if (count($name_parts) == 2)
        {
            $track['artist'] = trim($name_parts[0]);
            $track['song'] = trim($name_parts[1]);
        }
           
        
        return $track;
    }
    
    
}

?>